package com.yxinsur.imc.business.enums;

import com.yxinsur.imc.common.utils.StringUtils;
import lombok.Getter;

/**
 * 费率类型
 */
@Getter
public enum RateTypeEnum {

	/**
	 * 折标率
	 */
	R("R","折标率"),
	/**
	 * 佣金率
	 */
	C("C","佣金率"),
	/**
	 * 基础手续费率
	 */
	F("F","基础手续费率"),

	SR("SR","供应商折标系数"),

	YS("YS","供应商年期换算系数");

	private String code;
	private String name;

	private RateTypeEnum(String code,String name) {
		this.code = code;
		this.name = name;
	}

	/**
	 * 校验是否为枚举中的值
	 * @param code
	 * @return
	 */
	public static boolean isContain(String code){
		if(StringUtils.isBlank(code)){
			return false;
		}
		for (RateTypeEnum t : RateTypeEnum.values()) {
			if (t.getCode().equals(code.toUpperCase())) {
				return true;
			}
		}
		return false;
	}

	public static String getNameByCode(String code){
		String name=null;
		for (RateTypeEnum typeEnum : RateTypeEnum.values()) {
			if(typeEnum.getCode().equals(code)){
				name = typeEnum.getName();
				break;
			}
		}
		return name;
	}

}
